<!doctype html>
<html itemscope="itemscope" itemtype="http://schema.org/WebPage">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Json Edit - 感谢此源码作者</title>
<style>
::-webkit-scrollbar-track-piece{
	background-color:#fff;
	-webkit-border-radius:0;
}
::-webkit-scrollbar{
	width:8px;
	height:8px;
}
::-webkit-scrollbar-thumb{
	background-color:#999;
	-webkit-border-radius:4px;
	outline:2px solid #fff;
	outline-offset:-2px;
	border:2px solid #fff;
}
::-webkit-scrollbar-thumb:hover{
	background-color:#777;
}
* {
	margin:0px;
	padding:0px;
}
html {
	-webkit-box-sizing:border-box;
	-moz-box-sizing:border-box;
	box-sizing:border-box;
}
html,body {
	font-family:Monaco,Consolas,"Lucida Console","Courier New",serif;
	font-size:12px;
	color:#333;
	width:100%;
	height:100%;
	overflow:hidden;
}
body {
	-moz-user-select:none; 
	-khtml-user-select:none; 
	user-select:none;
}
div {
	border-collapse:collapse;
}
#ldh_ui_window{
	width:100%;
	height:100%;
	border:0px solid #4A84C4;
}
#ldh_ui_body_left{
	display:table-cell;
	overflow:auto;
	border-style:solid;
	border-color:#4A84C4;
	border-width:0px;
}
#editWindow{
	display:table-cell;
	width:100%;
	border-style:solid;
	border-color:#4A84C4;
	border-width:0px;
}
#tree_cap{
	display:table-row;
	height:29px;
	line-height:29px;
	text-align:center;
	background:url(image/img6.gif) repeat-x 50% 50%;
}
/* toolbar */
#subToolbar{
	display:table-row;
	width:inherit;
	height:29px;
	line-height:29px;
	background:url(image/img6.gif) repeat-x 50% 50%;
	text-indent:10px;
}
#subToolbar a{
	color:#000;
	background:url(image/img7.gif) no-repeat 0% 50%;
	padding-left:20px;
	text-decoration:none;
}
#subToolbar span{
	float:right;
	margin-right:10px;
}
#subToolbar a:hover{
	color:#fff;
	background-image:url(format.gif);
	text-decoration:underline;
}
#subToolbar a#save_as{
	background-image:url(image/img9.gif);
}
#subToolbar a#format_indent{
	background-image:url(image/img8.gif);
}
#subToolbar a#update{
	background-image:url(image/img10.gif);
}
#subToolbar a#format_compress{
	background-image:url(image/img11.gif);
}
#subToolbar a#clear_txt{
	background-image:url(image/img12.gif);
}
#subToolbar a#validate{
	background-image:url(image/img13.gif);
}
/* end */
#json_edit{
	width:100%;
	border:none;
	margin:0px;
	color:#000; 
	height:inherit;
	font-size:14px;
}
.json_editInfo{
	margin:3px;
	color:#003300;
	border:1px solid #4A84C4;
}
#json_editInfo{
	display:table-cell;
	padding-left:60px;
	vertical-align:middle;
	height:60px;
	background:url(image/img13.gif) no-repeat 28px 12px;
	overflow: auto;
}
#json_editInfo b{
	color:red
}
#ldh_ui_window .err{
	color:red;
	background-image:url(image/img14.gif);
}
#ldh_ui_window .busy{
	color:#333;
	background-image:url(image/img15.gif);
}
#ldh_ui_window .info{
	color:#006600;
	background-image:url(image/img16.gif);
}
#json_editInfo input{
	width:50px;
	border:1px solid #4A84C4;
	height:14px;
}
#json_editInfo  button{
	background:url(image/img17.gif) no-repeat;
	width:70px;
	height:20px;
	line-height:20px;
	text-align:center;
	border:none;
	color:#114060;
	letter-spacing:5px;
	margin-left:10px;
}
/* for tree */
img,input,select{
	vertical-align:middle;
}
#tree{
	width:300px;
	height:100%;
	line-height:24px;
	white-space:nowrap;
	font-size:12px;
	border-style:solid;
	border-color:#4A84C4;
	border-width:0px 1px 0px 0px;
	overflow:auto;
}
#tree a{
	text-decoration:none;
	color:#333;
}
/*#tree a:hover,#tree a.hot{color:#000;background:#0B92FF;}*/
#tree a:hover,#tree a.hot{
	color:#fff;
	background:#36c;
}
dd,dl,dt{
	padding:0;
	margin:0;
	border:none;
	font-size:12px;
}
dt img{
	vertical-align:middle;
}
dt{
	height:20px;
	white-space:nowrap;
}
#edit {
	display:table-row;
	height:100%;
}
#edit textarea {
	border:0px;
	width:100%;
	height:100%;
	line-height:19px;
	border-style:solid;
	border-color:#4A84C4;
	border-width:1px;
}
.search_f {
	position:fixed;
	left:0px;
	top:29px;
	width:300px;
	height:100%;
	line-height:27px;
	background:#fff;
}
.search_f * {
	margin:5px;
}
.search_f input {
	height:21px;
}
.search_f input[type=button] {
	width:75px;
	height:27px;
}
</style>
</head>
<body>
	<div id="ldh_ui_window">
		<div style="display:inline-table;width:100%;height:100%">
			<div id="ldh_ui_body_left">
				<div style="display:inline-table;width:100%;height:100%">
					<div id="tree_cap">树视图</div>
					<div style="display:table-row;height:100%">
						<div id="tree"></div>
					</div>
				</div>
			</div>
			<div id="editWindow">
				<div style="display:inline-table;width:100%;height:100%">
					<div id="subToolbar">
						<a href="javascript:void(0)" title="" id="format_indent">缩进</a> | 
						<a href="javascript:void(0)" title="" id="format_compress">紧凑</a> | 
						<a href="javascript:void(0)" title="" id="update">刷新视图</a> | 
						<a href="javascript:void(0)" title="" id="clear_txt">清空</a> | 
						<a href="javascript:void(0)" title="" id="save_as">另存为</a>
						<a href="javascript:void(0)" title="" id="validate">验证</a>
	
						<span>
							<label for="autoUpdate"><input type="checkbox" id="autoUpdate" checked /> 同步更新树视图</label>
						</span>
					</div>
					<div id="edit">
						<div style="display:table-cell;padding:3px;">
							<textarea id="json_edit" wrap="off"></textarea>
						</div>
					</div>
					<div style="display:table-row;height:80px">
						<fieldset class="json_editInfo">
							<legend>系统消息</legend>
							<div id="json_editInfo" class="busy">感谢此源码作者</div>
						</fieldset>
					</div>
				</div>
			</div>
		</div>
	</div>
	<form id="_search_f" class="search_f" style="display:none">
		<div>
			<div>查找: <input name="pattern" /></div>
			<div>替换: <input name="repl" /></div>
			<label><input name="c_i" type="checkbox" /> 区分大小写</label><br>
			<label><input name="c_f" type="checkbox" checked /> 循环搜索</label><br>
			<label><input name="c_r" type="checkbox" checked /> 正则表达式</label><br>
			<input name="b_0" type="button" value="查找" />
			<input name="b_2" type="button" value="替换/查找" /><br>
			<input name="b_1" type="button" value="替换" />
			<input name="b_3" type="button" value="替换全部" />
		</div>
	</form>
</body>
<script>

/*
main Object
*/

JE = {
	data:{},/* 关联数据 */
	code:false,/* 格式化后的代码 */
	oldCode:[],/* 历史代码 */
	editUI:null,/* 关联编辑框 */
	msgUI:null,/* 信息显示窗口 */
	treeUI:null,/* 树窗口 */
	name:'JE',/* 实例名 */
	root:'<b>~~~</b>',/* 根节点标题 */
	checkbox:0,/* 是否添加复框 */
	hot:null,/* 选中节点 */
	indent:'    ',/*缩进符'\t'或者4个' '*/
	onclick:Array,/*树点击通知*/
	countInfo:'',/*统计信息*/
	formating:false,/* 格式化中(禁止重构树) */
	updateTree:true,
	cursor:"",

	ico:{/* 树图标 */
		//文件夹结构线
		r0:'image/img18.gif',
		r0c:'image/img19.gif',
		r1:'image/img20.gif',
		r1c:'image/img21.gif',
		r2:'image/img22.gif',
		r2c:'image/img23.gif',
		//前缀图片
		nl:'image/img24.gif',
		vl:'image/img25.gif',
		//文件结构线
		f1:'image/img26.gif',
		f2:'image/img27.gif',
		root:'image/img28.gif',
		//文件夹
		arr:'image/img29.gif',
		arrc:'image/img30.gif',
		obj:'image/img31.gif',
		objc:'image/img32.gif',
		//文件
		arr2:'image/img33.gif',
		obj2:'image/img34.gif'
	},
	setCursor: function (cur) {
		JE.cursor = cur;
		if (setCursor) setCursor(cur);
	},
	reSetEdit: function (b) {
		JE.editUI.outerHTML = JE.editUI.outerHTML.replace(/(wrap\=[^\w]*)\w+([^\w]*)/, "$1" + (b == true ? "soft" : "off") + "$2");
		JE.editUI = $('json_edit');
		/* 监听代码变化事件 */
		JE.editUI.oninput=JE.editUI.onpropertychange=function (){
			if(JE.formating)return;/* 格式化不刷新树 */
			var _fText = JE.getFormatText(this.value);
			if(/^\s*$/.test(_fText))return  JE.msg('请输入JSON格式的代码!');;
			clearTimeout(JE.update);
			try{
				JE.data=eval('('+_fText+')');
			}catch(e){
				JE.editUI.style.color='#990000';
				return JE.msg("源代码有错误: "+e.description+' , 如果正在编辑中, 请忽略此消息!','err');
			};
			JE.editUI.style.color='#000';
			if (JE.updateTree){/*若同步*/
				JE.msg('语法正确,正在重新构造树,请稍候...','busy');
				JE.update=setTimeout(function(){
					JE.toTree();
				},450);
			}else{
				JE.msg('语法正确,请点击刷新,或者打开视图同步开关,或者继续编辑!')
			}
			return true;
		};
	},
	toTree:function(){/* JSON转换为树HTML,同时格式化代码 */
		var draw=[],This=this,ico=this.ico;
		var notify=function(prefix/*前缀HTML*/,lastParent/*父是否是尾节点(确定图标是空白|结构线)*/,name/*节点名*/,value/*节点值*/,formObj/* 父是否是对象(确定子图标) */){/* 构造子节点 */
			var rl=prefix==''?ico.r0:lastParent?ico.r1:ico.r2;/* 配置根节点图标 */
			if(value&&value.constructor==Array){/* 处理数组节点 */
				draw.push('<dl><dt>',This.draw(prefix,rl,ico.arr,name,''),'</dt><dd>');/* 绘制文件夹 */
				for (var i=0;i<value.length;i++)
					notify(prefix+This.img(lastParent?ico.nl:ico.vl),i==value.length-1,i,value[i]);
				draw.push('</dd></dl>');
			}else	if(value&&typeof value=='object'){/* 处理对象节点 */
					draw.push('<dl><dt>',This.draw(prefix,rl,ico.obj,name,''),'</dt><dd>');/* 绘制文件夹 */
					var len=0,i=0;
					for(var key in value)len++;/* 获取对象成员总数 */
					for(var key in value)notify(prefix+This.img(lastParent?ico.nl:ico.vl),++i==len,key,value[key],true);
					draw.push('</dd></dl>');
				}else{/* 处理叶节点(绘制文件) */
					draw.push('<dl><dt>',This.draw(prefix,lastParent?ico.f1:ico.f2,formObj?ico.obj2:ico.arr2,name,value),'</dt></dl>');
				};
		};/* 不是[]或者{}不绘制 */
		if(typeof this.data=='object'){notify('',true,this.root,this.data);};
		if(this.treeUI)this.treeUI.innerHTML=draw.join('');/* 显示在树窗口 */
		this.msg('成功构造树视图!');
	},

	draw:function(prevfix,line,ico,name,value){/* 子项HTML构造器 */
		var cmd=false,J=this.ico,imgName=false;
		switch (line)	{//传递切换图标
			case J.r0:imgName='r0';break;
			case J.r1:imgName='r1';break;
			case J.r2:imgName='r2';
		}
		if(imgName)cmd=' onclick="'+this.name+'.show(this,\''+imgName+'\')" ';/* 加入折叠命令 */
		//var type=typeof name=='string'?'(对象成员)':'(数组索引)';
		var type=typeof name=='string'?'':' ~';
		return prevfix+this.img(line,cmd)
			+(this.checkbox?'<input type="checkbox" onclick="'+this.name+'.select(this)" />':'')
			+this.img(ico)+' <a href="javascript:void(0)" onclick="'+this.name+'.click(this);" '
			+'key="'+name+'" val="'+value+'" >'
			+name+type+(imgName?'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;':' = ')+value+'</a>'
	},
	img:function(src,attr){/* img HTML构造 */
		return '<img src="'+src+'" '+(attr||'')+'  />';
	},
	click:function(item){/* 子项点击统一回调 */
		if(this.hot)this.hot.className='';
		this.hot=item;
		this.hot.className='hot';/* 切换选中项 */
//		this.onclick(item);
	},

	format:function(txt,compress/*是否为压缩模式*/){/* 格式化JSON源码(对象转换为JSON文本) */
		if(/^\s*$/.test(txt))return this.msg('数据为空,无法格式化! ');
		try{var data=eval('('+txt+')');}
		catch(e){
			JE.editUI.style.color='#990000';
			return this.msg('数据源语法错误,格式化失败! 错误信息: '+e.description,'err');
		};
		JE.editUI.style.color='#000';
		var draw=[],last=false,This=this,line=compress?'':'\n',nodeCount=0,maxDepth=0;
		var notify=function(name,value,isLast,indent/*缩进*/,formObj){
			nodeCount++;/*节点计数*/
			for (var i=0,tab='';i<indent;i++ )tab+=This.indent;/* 缩进HTML */
			tab=compress?'':tab;/*压缩模式忽略缩进*/
			maxDepth=++indent;/*缩进递增并记录*/
			if (typeof(name) == 'string') name = name.replace(/([\\"\\'])/g, "\\\$1");
			if(value&&value.constructor==Array){/*处理数组*/
				draw.push(tab+(formObj?('"'+name+'":'):'')+'['+line);/*缩进'[' 然后换行*/
				for (var i=0;i<value.length;i++)
					notify(i,value[i],i==value.length-1,indent,false);
				draw.push(tab+']'+(isLast?line:(','+line)));/*缩进']'换行,若非尾元素则添加逗号*/
			}else	if(value&&typeof value=='object'){/*处理对象*/
					draw.push(tab+(formObj?('"'+name+'":'):'')+'{'+line);/*缩进'{' 然后换行*/
					var len=0,i=0;
					for(var key in value)len++;
					for(var key in value)notify(key,value[key],++i==len,indent,true);
					draw.push(tab+'}'+(isLast?line:(','+line)));/*缩进'}'换行,若非尾元素则添加逗号*/
				}else{
						if(typeof value=='string')value='"'+value.replace(/([\\"\\'])/g, "\\\$1")+'"';
						draw.push(tab+(formObj?('"'+name+'":'):'')+value+(isLast?'':',')+line);
				};
		};
		var isLast=true,indent=0;
		notify('',data,isLast,indent,false);
		this.countInfo='共处理节点<b>'+nodeCount+'</b>个,最大树深为<b>'+maxDepth+'</b>';
		return draw.join('');
	},
	msg:function(text,type){/* 编辑状态或者错误通知 */
		if(!this.msgUI)return alert(text);
		with(new Date)var now=([getHours(),getMinutes(),getSeconds()].join(':')).replace(/\b\d\b/g,'0$&');
		this.msgUI.innerHTML='<div>['+now+'] &nbsp;&nbsp;'+text.replace(/\n/g,'<br/>')+'</div>';
		this.msgUI.className=type;
	},
	show:function (ico,id){/* 显隐树节点 */
		var subView=ico.parentNode.parentNode.childNodes[1].style,J=this.ico;
		if(subView.display=='none'){
			subView.display='';
			 ico.src=J[id];
		}else{
			subView.display='none';
			 ico.src=J[id+'c'];
		};
	},
	select:function (sender){
		var sub=sender.parentNode.parentNode.getElementsByTagName("INPUT");
		for (var i=0;i<sub.length;i++ ) {sub[i].checked=sender.checked;}
	},
	format2:function(compress){
		var code=JE.format(JE.editUI.value.replace(/\s*[\n\r]+\s*/g, ""), compress);
		JE.formating=true;
		if (code) {
			code = code.replace(/[\s\n\r]+$/g, "");
			var b = /off/.test(JE.editUI.outerHTML);
			if (compress == true) {
				if (b == true) {
					JE.reSetEdit(b);
				}
			}
			else if (b == false) {
				JE.reSetEdit(b);
			}
			JE.editUI.value=code;
		}
		JE.editUI.focus();
		setTimeout(function(){JE.formating=false;},1000);
		return code;
	},
	getFormatText:function (text) {
		return text.replace(/\s*[\n\r]+\s*/g, "");
	},
	showError:function(error) {
		JE.editUI.setSelectionRange(error.location, error.location);
		JE.msg(error.message, 'err');
		JE.autoScroll();
	},
	setSelectRange: function(view, start, end) {
		if (typeof view.createTextRange != 'undefined' ) {
			var range = view.createTextRange();
			range.moveStart("character", 0)
			range.moveEnd("character", 0);
			range.collapse(true); 
			range.moveEnd("character", end);
			range.moveStart("character", start);
			range.select();
		}
		else if (typeof view.setSelectionRange != 'undefined' ) {
			view.setSelectionRange(start, end);
			view.focus();
		}
	},
	search: function () {
		var p = $("_search_f").pattern.value;
		var v = JE.editUI.value;
		if ($("_search_f").c_r.checked == false) {
			if ($("_search_f").c_i.checked == false) {
				p = p.toUpperCase();
				v = v.toUpperCase();
			}
			var f_0 = function (i) {
				i = v.indexOf(p, i);
				if (i != -1) {
					JE.setSelectRange(JE.editUI, i, i + p.length);
				}
				return i;
			}
			var i = f_0(JE.editUI.selectionEnd);
			if (i == -1) {
				if ($("_search_f").c_f.checked == true) {
					f_0(0);
				}
				else {
					alert("none");
				}
			}
		}
		else {
			var r = new RegExp(p, "g" + ($("_search_f").c_i.checked == true ? "" : "i"));
			var f_1 = function (i) {
				r.lastIndex = i;
				var o = r.exec(v);
				if (null != o) {
					i = r.lastIndex;
					JE.setSelectRange(JE.editUI, i - o[0].length, i);
				}
				else {
					i = -1;
				}
				return i;
			}
			var i = f_1(JE.editUI.selectionEnd);
			if (i == -1) {
				if ($("_search_f").c_f.checked == true) {
					f_1(0);
				}
				else {
					alert("none");
				}
			}
		}
		JE.editUI.focus();
		JE.autoScroll();
	},
	replaceOnce: function () {
		var start = JE.editUI.selectionStart;
		var end = JE.editUI.selectionEnd;
		if (start != end) {
			var pl = $("_search_f").repl.value;
			var v = JE.editUI.value;
			v = v.substr(0, start) + pl + v.substr(end);
			start += pl.length;
			JE.editUI.value = v;
			JE.setSelectRange(JE.editUI, start, start);
		}
		JE.editUI.focus();
		JE.autoScroll();
	},
	replaceAndSearch: function () {
		JE.replaceOnce();
		JE.search();
		JE.autoScroll();
	},
	replaceAll: function () {
		var p = $("_search_f").pattern.value;
		var pl = $("_search_f").repl.value;
		var v = JE.editUI.value;
		if ($("_search_f").c_r.checked == false) {
			var ov = v;
			if ($("_search_f").c_i.checked == false) {
				p = p.toUpperCase();
				v = v.toUpperCase();
			}
			var l = p.length;
			var i = 0;
			while ((i = v.indexOf(p, i)) != -1) {
				ov = ov.substr(0, i) + pl + ov.substr(i + l);
				v = ov;
				if ($("_search_f").c_i.checked == false) {
					v = v.toUpperCase();
				}
			}
			JE.editUI.value = ov;
		}
		else {
			var r = new RegExp(p, "g" + ($("_search_f").c_i.checked == true ? "" : "i"));
			JE.editUI.value = v.replace(r, pl);
		}
		JE.editUI.focus();
		JE.autoScroll();
	},
	showSearch: function() {
		var b = $("_search_f").style.display == "none";
		$("_search_f").style.display = (b == true ? "" : "none");
		if (b) {
			$("_search_f").style.width = $("tree").style.width;
			$("_search_f").b_0.onclick = JE.search;
			$("_search_f").b_1.onclick = JE.replaceOnce;
			$("_search_f").b_2.onclick = JE.replaceAndSearch;
			$("_search_f").b_3.onclick = JE.replaceAll;
			$("_search_f").pattern.focus();
			$("tree").innerHTML = "";
			JE.updateTree = false;
		}
		else {
			$("_search_f").b_0.onclick = null;
			$("_search_f").b_1.onclick = null;
			$("_search_f").b_2.onclick = null;
			$("_search_f").b_3.onclick = null;
			JE.updateTree = $("autoUpdate").checked;
			$("update").onclick();
		}
	},
	autoScroll: function () {
		var start = JE.editUI.selectionStart;
		var v = JE.editUI.value;
		v = v.substr(0, start);
		var l = v.split(/[\r\n]/).length - 5;
		JE.editUI.scrollTop = l * 19;
	}
};

JE.add=function(){
	this.msg('功能添加中...*_^');
}

JE.editItem=function(){
	this.msg('功能添加中...*_^');
}
var $=function (id){return document.getElementById(id)};
JE.begin=function(){/* 设置UI控件关联响应 */
//	var $=function (id){return document.getElementById(id)};
	/* 关联UI */
	JE.editUI=$("json_edit");
	JE.msgUI=$("json_editInfo");
	JE.treeUI=$("tree");
	var updateUI=$("update");
	var auto=$("autoUpdate");
	var fontSize=$("fontSize");
	JE.updateTree = auto.checked;
	JE.reSetEdit(false);
	/* 单击树子项 */
	JE.onclick=function(item){
		var key='键名: <input value="'+item.getAttribute('key')+'" />',
			val='  键值: '+(item.getAttribute('val')==''?'成员列表':'<input value="'+item.getAttribute('val')+'" />'),
			add='<button onclick="'+this.name+'.add(this)">新增</button>',
			edit='<button onclick="'+this.name+'.editItem(this)">修改</button>';
		JE.msg(key+val+add+edit,'info');
	}
	document.body.onkeydown = function () {
		if (event.target == JE.editUI) {
			if (event.keyCode == 9) {
				var start = JE.editUI.selectionStart;
				if (event.ctrlKey == true || event.shiftKey == true) {
					$('format_compress').onclick();
				}
				else {
					$('format_indent').onclick();
				}
				event.preventDefault();
				event.stopPropagation();
				JE.setSelectRange(JE.editUI, start, start);
				JE.autoScroll();
			}
		}
		if (event.shiftKey == true) {
			switch (event.keyCode) {
				case 46:
					$('clear_txt').onclick();
					event.preventDefault();
					event.stopPropagation();
					return;
					break;
			}
			if (event.ctrlKey == true) {
				switch (event.keyCode) {
					case 65:
						$('update').onclick();
						event.preventDefault();
						event.stopPropagation();
						return;
						break;
					case 83:
						$('validate').onclick();
						event.preventDefault();
						event.stopPropagation();
						return;
						break;
				}
			}
		}
		if (event.ctrlKey == true) {
			switch (event.keyCode) {
				case 65:
				case 67:
				case 88:
				case 86:
				case 89:
				case 90:
				case 36:
				case 35:
				case 8:
				case 13:
				case 46:
					break;
				case 70:
					JE.showSearch();
					event.preventDefault();
					event.stopPropagation();
					break;
				default:
					event.preventDefault();
					event.stopPropagation();
					break;
			}
		}
		/*
		a:65
		c:67
		x:88
		v:86
		
		y:89
		z:90
		
		home:36
		end:35
		
		backspace:8
		enter:13
		delete:46
		
		q:81
		w:87
		r:82
		t:84
		o:79
		s:83
		f:70
		h:72
		*/
	}
	/* 工具栏按钮 */
	$('format_indent').onclick = function () {
		if (JE.format2()) {
			JE.msg('完成缩进风格转换,' + JE.countInfo);
		}
	}
	$('format_compress').onclick = function () {
		if (JE.format2(true) != undefined) {
			JE.msg('完成紧凑风格转换,' + JE.countInfo);
		}
	}
	updateUI.onclick = function (){
		JE.editUI.oninput() ? JE.msg('成功刷新视图!') : JE.msg('数据有误,刷新失败!', 'err');
	}
	$('clear_txt').onclick = function () {
		JE.editUI.value = JE.treeUI.innerHTML = '';
		JE.editUI.focus();
	}
	auto.onclick = function () {
		JE.msg('自动同步视图功能' + (this.checked ? '开启' : '关闭!'));
		if ($("_search_f").style.display != "none") return;
		JE.updateTree = this.checked;
		if (this.checked) {
			updateUI.onclick();
		}
		else {
			$('tree').innerHTML = "";
		}
	}
	/* 另存为 */
	if(/*@cc_on !@*/true) {
		$('save_as').style.display = 'none';
	}
	$('save_as').onclick = function () {
		var d = document, w = d.createElement('IFRAME');
		w.style.display = "none";
		d.body.appendChild(w);
		setTimeout(function () {
			var g = w.contentWindow.document;
			g.charset = 'utf-8';
			g.body.innerHTML = JE.editUI.value;
			g.execCommand("saveas", '', "json.txt");
		}, 1);
	}
	$('validate').onclick = function () {
		if (jsonValidate) jsonValidate();
	}
	document.body.onmousemove = function (e) {
		var tr = $('tree');
		var _x = e.clientX - tr.offsetWidth - tr.offsetLeft;
		var _y = e.clientY - $('tree_cap').offsetHeight - $('tree_cap').offsetTop;
		if (_y <= 0) {
			JE.setCursor("auto");
			document.body.onmousedown = null;
			return;
		}
		else if (_x >= 0 && _x < 3) {
			var dMV = arguments.callee;
			JE.setCursor("cursor_v_split");
			if (document.body.onmousedown) return;
			document.body.onmousedown = function () {
				JE.setCursor("cursor_v_split");
				document.body.onmousemove = null;
				document.onmouseup = function () {
					JE.setCursor("auto");
					document.body.onmousemove = dMV;
					document.body.onmousedown = null;
					document.body.onmouseup = null;
				}
				var _w;
				document.body.onmousemove = function (e) {
					_w = e.clientX - tr.offsetLeft;
					_w = _w < 300 ? 300 : _w;
					_w = _w > document.body.offsetWidth - 500 ? document.body.offsetWidth - 500 : _w;
					$("_search_f").style.width = tr.style.width = _w + "px";
				}
			}
		}
		else {
			JE.setCursor("auto");
			document.body.onmousedown = null;
		}
	}
};

/* 从这里开始 */
window.onload=function (){
	JE.begin();
}

</script>
</html>